package com.ruoyi.framework.web.service;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.CdUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.system.domian.jpa.CdUserJpa;
import com.ruoyi.system.domian.service.CdUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @author Dale Mao    ---多多 Email:453918229@qq.com
 * @description ClientUserDetailsServiceImpl
 * @date 2021-01-27 22:53
 */
@Service
public class ClientUserDetailsServiceImpl implements  UserDetailsService {

    @Autowired
    CdUserService cdUserService;

    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        System.out.println("客官进来看看吧");

        CdUserJpa cdUser =cdUserService.getUserInfoByPhone(s);
        CdUser cdUsers =new CdUser();
        BeanUtils.copyProperties(cdUser,cdUsers);
        LoginUser loginUser = new LoginUser();
        loginUser.setCdUser(cdUsers);



        return loginUser;
    }

}
